-- 活动场的函数库
---@class ActivityFunctions
local Act = {}

--- 询问一名玩家从众多选项中选择一个。
---@param player ServerPlayer @ 要询问的玩家
---@param choices string[] @ 可选选项列表
---@param skill_name? string @ 技能名
---@param prompt? string @ 提示信息
---@param cancelable? boolean @ 可以取消吗
---@param all_choices? string[] @ 所有选项（不可选变灰）
---@return string @ 选择的选项
function Act.askForChoice(player, choices, skill_name, prompt, cancelable, all_choices)
  if #choices == 1 and (not all_choices) then return choices[1] end
  assert(not all_choices or table.every(choices, function(c) return table.contains(all_choices, c) end))
  local room = player.room
  prompt = prompt or ""
  all_choices = all_choices or choices
  if cancelable then
    table.insertIfNeed(choices, "Cancel")
    table.insertIfNeed(all_choices, "Cancel")
  end
  room:notifyMoveFocus(player, (skill_name or "$Choicetabs") )
  local data = {choices, all_choices, prompt}
  local result = room:askForCustomDialog(player, skill_name or "$Choicetabs", "packages/activities/qml/ChoicetabsBox.qml", data)
  if result == "" then
    if table.contains(choices, "Cancel") then
      result = "Cancel"
    else
      result = choices[1]
    end
  end
  return result
end

Fk:loadTranslationTable{
  ["$Choicetabs"] = "选择选项"
}

return Act
